//package abandon;
//
//import data.Markers;
//import data.Window;
//import org.apache.commons.lang3.ArrayUtils;
//import util.Calculate;
//import util.Judge;
//import util.RandomGen;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//import java.util.Random;
//
///*
// * 分段类
// * Sample:样本号
// * chromosome:染色体
// * start:起始位点
// * end:终止位点
// * countsOfProbes:分段上探针总数
// * log_ratio:值:(log(X/2))
// *
// * */
//public class Segments {
//    private String[] sample;
//    private String[] chromosome;
//    private String[] start;
//    private String[] end;
//    private String[] countsOfProbes;
//    private String[] log_ratio;
//    private String[] colName;
//
//    public String[] getColName() {
//        return colName;
//    }
//
//    public void setColName(String[] colName) {
//        this.colName = colName;
//    }
//
//    public String[] getSample() {
//        return sample;
//    }
//
//    public void setSample(String[] sample) {
//        this.sample = sample;
//    }
//
//    public String[] getChromosome() {
//        return chromosome;
//    }
//
//    public void setChromosome(String[] chromosome) {
//        this.chromosome = chromosome;
//    }
//
//    public String[] getStart() {
//        return start;
//    }
//
//    public void setStart(String[] start) {
//        this.start = start;
//    }
//
//    public String[] getEnd() {
//        return end;
//    }
//
//    public void setEnd(String[] end) {
//        this.end = end;
//    }
//
//    public String[] getCountsOfProbes() {
//        return countsOfProbes;
//    }
//
//    public void setCountsOfProbes(String[] countsOfProbes) {
//        this.countsOfProbes = countsOfProbes;
//    }
//
//    public String[] getLog_ratio() {
//        return log_ratio;
//    }
//
//    public void setLog_ratio(String[] log_ratio) {
//        this.log_ratio = log_ratio;
//    }
//
//
//    /*
//     * 将文件取出来的值赋值
//     * list:提取的数据（每一个元素是一行数据，未被分割）
//     * symbol:分割符
//     * col_title:是否具有列名
//     *
//     * */
//    public void assign(List list, String symbol, boolean col_title){
//        int row_length = col_title?list.size()-1:list.size();
//        int column_length = list.get(0).toString().split(symbol).length;
//        String[] lineData = new String[column_length];
//
//        sample = new String[row_length];
//        chromosome = new String[row_length];
//        start = new String[row_length];
//        end = new String[row_length];
//        countsOfProbes = new String[row_length];
//        log_ratio = new String[row_length];
//        colName = col_title?list.get(0).toString().split(symbol):null;
//
//        for (int i= 0 ;i<row_length;i++){
//            if(colName==null){
//                lineData = list.get(i).toString().split(symbol);
//            }else {
//                lineData = list.get(i+1).toString().split(symbol);
//            }
//            int j = 0;
//            this.sample[i] = lineData[j++];
//            this.chromosome[i] = lineData[j++];
//            this.start[i] = lineData[j++];
//            this.end[i] = lineData[j++];
//            this.countsOfProbes[i] = lineData[j++];
//            this.log_ratio[i] = lineData[j];
//        }
//    }
//
//
//    /*
//     * 模拟数据（指定窗口位置和乘客数量后，再分段）
//     * 【单种染色体】
//     * basicNumber:基础流水号
//     * samplesNumber:样本数量
//     * colName:列名
//     * markers:生成的标记
//     * windows:窗口（驱动基因）
//     *
//     * */
////    public void stimulateSpecifically(String basicNumber,int samplesNumber,int passengersNumber,String[] colName,Markers markers,Window windows){
////        Random random = new Random(); //随机对象
////        int w_midPos = windows.getMidPos(); //窗口中点
////        int w_width = windows.getWidth(); //窗口长度
////        double w_LRRVal = windows.getValue(); //窗口值
////        int p_number = passengersNumber;
////        double p_value; //乘客值
////        int m_number = markers.getM_detail().totalNumber;
////
////        if (w_LRRVal>0){
////            p_value = Constant.default_positivePassengersValue;
////        }else {
////            p_value = Constant.default_negativePassengersValue;
////        }
////
////        int total_segNumber = 0; //计算出所有的分段数
////        List<List> segment_allSamples = new ArrayList<List>();
////
////        for (int i=0;i<samplesNumber;i++){
////            segment_allSamples.add(segmentPerSampleSpecifically(basicNumber,i,m_number,p_number,p_value,w_midPos,w_width,w_LRRVal));
////            total_segNumber += ( (String[])segment_allSamples.get(i).get(0) ).length;
////        }
////
////
////        //赋予Segment参数值
////        sample = new String[total_segNumber];
////        chromosome = new String[total_segNumber];
////        start = new String[total_segNumber];
////        end = new String[total_segNumber];
////        countsOfProbes = new String[total_segNumber];
////        log_ratio = new String[total_segNumber];
////        this.colName = colName;
////
////        int order = 0;
////        List segmentPerSample;
////        String[] serialNumberPerSamples;
////        String[] chromosomePerSamples;
////        int[] startPointPerSamples;
////        int[] endPointPerSamples;
////        int[] countsOfProbesPerSamples;
////        int[] log_ratioPerSamples;
////
////        for (int i=0;i<samplesNumber;i++){
////            segmentPerSample = segment_allSamples.get(i);
////            serialNumberPerSamples = (String[])segmentPerSample.get(0);
////            chromosomePerSamples = (String[])segmentPerSample.get(1);
////            startPointPerSamples = (int[])segmentPerSample.get(2);
////            endPointPerSamples = (int[])segmentPerSample.get(3);
////            countsOfProbesPerSamples = (int[])segmentPerSample.get(4);
////            log_ratioPerSamples = (int[])segmentPerSample.get(5);
////
////            for (int j=0;j<segNumberPerSamples[i];j++){
////                sample[order] = String.valueOf(serialNumberPerSamples[j]);
////                chromosome[order] = String.valueOf(chromosomePerSamples[j]);
////                start[order] = String.valueOf(startPointPerSamples[j]);
////                end[order] = String.valueOf(endPointPerSamples[j]);
////                countsOfProbes[order] = String.valueOf(countsOfProbesPerSamples[j]);
////                log_ratio[order] = String.valueOf(log_ratioPerSamples[j]);
////                order++;
////            }
////        }
////    }
//
//
//    /*
//     * 模拟数据（随机分段后，再赋值【窗口区域与分段区域交错即改变分段区域值】）
//     * basicNumber:基础流水号
//     * samplesNumber:样本数量
//     * colName:列名
//     * markers:生成的标记
//     * windows:窗口（驱动基因）
//     *
//     * */
//    public void stimulateRandomly(String basicNumber, int samplesNumber, String[] colName, Markers markers, Window windows){
//        Random random = new Random(); //随机对象
//        Markers.M_Detail m_detail = markers.getM_detail(); //markers的细节
//        int[] m_startArray = m_detail.start; //起始点集
//        int[] m_endArray = m_detail.end; //终止点集
//        int w_midPos = windows.getMidPos(); //窗口中点
//        int w_width = windows.getWidth(); //窗口长度
//        double w_LRRVal = windows.getValue(); //窗口值
//        List<List> segment_allSamples = new ArrayList<List>();
//
//        //创建每个样本的分段数
//        int chromosomeNumber = Judge.differentType(markers.getChromosome()); //染色体种类数目
//        int minProbesInChrom = Calculate.getMin(m_detail.probesPerChrom); //染色体中的最少探针数
//        int[] segNumberPerSamples = new int[samplesNumber]; //每一个样本的分段数目（随机）
//        int total_segNumber = 0;
//        for (int i=0;i<samplesNumber;i++){
//            //每一个样本的分段数量不应超过染色体中最少的探针数及小于染色体种类数
//            segNumberPerSamples[i] = random.nextInt(minProbesInChrom)%(minProbesInChrom-chromosomeNumber+1) + chromosomeNumber;
//            total_segNumber += segNumberPerSamples[i];
//            segment_allSamples.add(segmentPerSampleRandomly(basicNumber,i,segNumberPerSamples[i],chromosomeNumber,m_startArray,m_endArray,w_midPos,w_width,w_LRRVal));
//        }
//
//
//
//        //赋予Segment参数值
//        sample = new String[total_segNumber];
//        chromosome = new String[total_segNumber];
//        start = new String[total_segNumber];
//        end = new String[total_segNumber];
//        countsOfProbes = new String[total_segNumber];
//        log_ratio = new String[total_segNumber];
//        this.colName = colName;
//
//        int order = 0;
//        List segmentPerSample;
//        String[] serialNumberPerSamples;
//        String[] chromosomePerSamples;
//        int[] startPointPerSamples;
//        int[] endPointPerSamples;
//        int[] countsOfProbesPerSamples;
//        int[] log_ratioPerSamples;
//
//        for (int i=0;i<samplesNumber;i++){
//            segmentPerSample = segment_allSamples.get(i);
//            serialNumberPerSamples = (String[])segmentPerSample.get(0);
//            chromosomePerSamples = (String[])segmentPerSample.get(1);
//            startPointPerSamples = (int[])segmentPerSample.get(2);
//            endPointPerSamples = (int[])segmentPerSample.get(3);
//            countsOfProbesPerSamples = (int[])segmentPerSample.get(4);
//            log_ratioPerSamples = (int[])segmentPerSample.get(5);
//
//            for (int j=0;j<segNumberPerSamples[i];j++){
//                sample[order] = String.valueOf(serialNumberPerSamples[j]);
//                chromosome[order] = String.valueOf(chromosomePerSamples[j]);
//                start[order] = String.valueOf(startPointPerSamples[j]);
//                end[order] = String.valueOf(endPointPerSamples[j]);
//                countsOfProbes[order] = String.valueOf(countsOfProbesPerSamples[j]);
//                log_ratio[order] = String.valueOf(log_ratioPerSamples[j]);
//                order++;
//            }
//        }
//    }
//
//
//    /*
//     * 模拟数据（来源真实数据）(建立一个abberation list，以“抽奖”方式取出相应值，并覆盖相应分段)
//     * basicNumber:基础流水号
//     * samplesNumber:样本数量
//     * colName:列名
//     * markers:生成的标记
//     * windows:窗口（驱动基因）
//     *
//     * */
//    public void stimulateFromRealData(String basicNumber,int samplesNumber,String[] colName,Markers markers,Window windows){
//
//    }
//
//
//
//    /*
//     * 对单个样本(sample)产生随机分段（但窗口位置是指定的），用于stimulateRandomly方法
//     * basicNumber:基础流水号
//     * sampleOrder:样本号
//     * totalSegmentPerSample:某个样本的分段总数
//     * chromosomeNumber:染色体种类数目
//     * chromStartPoint:某种染色体的起始点集
//     * chromEndPoint:某种染色体的终止点集
//     * windowMidPos:窗口中心点的位置
//     * windowWidth:窗口范围
//     * windowLRRVal:窗口值
//     *
//     * */
//    private List segmentPerSampleRandomly(String basicNumber,int sampleOrder, int totalSegmentPerSample,
//                                          int chromosomeNumber, int[] chromStartPoint,int[] chromEndPoint,
//                                          int windowMidPos,int windowWidth, double windowLRRVal){
//        //计算单个样本中每个染色体的分割点的位置
//        int[] segmentNumberPerChrom = new int[chromosomeNumber];
//
//        segmentNumberPerChrom = RandomGen.randomSpliting(chromosomeNumber,totalSegmentPerSample); //求每个染色体的分段数目
//        int[][] positionPerChrom = new int[chromosomeNumber][]; //每个染色体中分段点的位置
//        for (int i=0;i<chromosomeNumber;i++){
//            positionPerChrom[i] = new int[segmentNumberPerChrom[i]-1]; //n个分割点，会形成n+1分段
//            do {
//                positionPerChrom[i] = RandomGen.randomCommon(chromStartPoint[i],chromEndPoint[i],segmentNumberPerChrom[i]-1);
//            }while (ArrayUtils.contains(positionPerChrom[i],chromStartPoint[i])); //因为randomCommon是左闭右开的，所以避免取分割点取到起点
//            Arrays.sort(positionPerChrom[i]);
//        }
//
//        String[] samplePerSegment = new String[totalSegmentPerSample];
//        String[] chromosomePerSegment = new String[totalSegmentPerSample];
//        int[] startPointPerSegment = new int[totalSegmentPerSample];  // 每个分段起始位点
//        int[] endPointPerSegment = new int[totalSegmentPerSample]; // 每个分段结束位点
//        int[] countsOfProbesPerSegment = new int[totalSegmentPerSample];
//        double[] log_ratioPerSegment = new double[totalSegmentPerSample]; //每个分段的log值
//        List Segment = new ArrayList<>();
//
//        //流水号
//        String serial_number;
//        for (int i=0;i<totalSegmentPerSample;i++){
//            serial_number = String.valueOf(sampleOrder+1);
//            serial_number = basicNumber.substring(0, basicNumber.length()-serial_number.length())+serial_number; //将序号和流水基础号组合
//            samplePerSegment[i] = serial_number;
//        }
//
//        //染色体
//        int order = 0;
//        for (int i=0;i<chromosomeNumber;i++){
//            for (int j=0;j<segmentNumberPerChrom[i];j++){
//                if (i==22){
//                    chromosomePerSegment[order++] = "X";
//                }else {
//                    chromosomePerSegment[order++] = String.valueOf(i+1);
//                }
//            }
//        }
//
//        //起始点
////        order = 1;
////        startPoint[0] = 0;
//        order = 0;
//        for (int i=0;i<chromosomeNumber;i++){
//            for (int j=0;j<segmentNumberPerChrom[i];j++){
//                if (segmentNumberPerChrom[i]==1){
//                    startPointPerSegment[order++] = chromStartPoint[i];
//                }else {
//                    if (j==0){
//                        startPointPerSegment[order++] = chromStartPoint[i];
//                    }else {
//                        startPointPerSegment[order++] = positionPerChrom[i][j-1]+1;
//                    }
//                }
//            }
//        }
//
//        //终止点
//        order = 0;
//        for (int i=0;i<chromosomeNumber;i++){
//            if (segmentNumberPerChrom[i] == 1){
//                endPointPerSegment[order++] = chromEndPoint[i];
//            }else {
//                for (int j=0;j<segmentNumberPerChrom[i];j++){
//                    if(j == segmentNumberPerChrom[i]-1){
//                        endPointPerSegment[order++] = chromEndPoint[i];
//                    }else {
//                        endPointPerSegment[order++] = positionPerChrom[i][j];
//                    }
//                }
//            }
//        }
//        //endPoint[order] = chromEndPoint[chromosomeNumber-1];//最后一个点
//
//
//
//
//        //探针数
//        for (int i=0;i<totalSegmentPerSample;i++){
//            countsOfProbesPerSegment[i] = endPointPerSegment[i] - startPointPerSegment[i] + 1;
//        }
//
//        //log_ratio值
//        //与窗口交融的分段都设值为LRRVal
//        int windowStartPoint = windowMidPos - windowWidth/2;
//        int windowEndPoint = windowMidPos + windowWidth/2;
//        for (int i=0;i<totalSegmentPerSample;i++){
//            if (windowStartPoint<endPointPerSegment[i] && windowEndPoint>startPointPerSegment[i]){
//                log_ratioPerSegment[i] = windowLRRVal;
//            }else {
//                log_ratioPerSegment[i] = 0;
//            }
//        }
//
//        //赋值
//        Segment.add(samplePerSegment);
//        Segment.add(chromosomePerSegment);
//        Segment.add(startPointPerSegment);
//        Segment.add(endPointPerSegment);
//        Segment.add(countsOfProbesPerSegment);
//        Segment.add(log_ratioPerSegment);
//
//        return Segment;
//    }
//
//
//    /*
//     * 对单个样本(sample)产生指定分段（驱动和乘客安置好后，再分段），用于stimulateSpecifically方法
//     * 【单种染色体】
//     * basicNumber:基础流水号
//     * sampleOrder:样本号
//     * totalSegmentPerSample:某个样本的分段总数
//     * chromosomeNumber:染色体种类数目
//     * chromStartPoint:某种染色体的起始点集
//     * chromEndPoint:某种染色体的终止点集
//     * windowMidPos:窗口中心点的位置
//     * windowWidth:窗口范围
//     * windowLRRVal:窗口值
//     *
//     * */
////    private List segmentPerSampleSpecifically(String basicNumber,int sampleOrder,int markersNumber,int passengersNumber,double passengersValue,
////                                              int windowMidPos, int windowWidth, double windowLRRVal){
////
////        double[] log_ratio_PerSample = new double[markersNumber];
////
////        //添加passengers
////        int passengerStart;
////        Random rd=new Random();
////        for(int i=0;i<passengersNumber;i++){
////            passengerStart=rd.nextInt(length-50);
////            for(int j=passengerStart;j<passengerStart+50;j++){
////                log_ratio_PerSample[j] = passengersValue;
////            }
////        }
////
//////        String[] samplePerSegment = new String[totalSegmentPerSample];
//////        String[] chromosomePerSegment = new String[totalSegmentPerSample];
//////        int[] startPointPerSegment = new int[totalSegmentPerSample];  // 每个分段起始位点
//////        int[] endPointPerSegment = new int[totalSegmentPerSample]; // 每个分段结束位点
//////        int[] countsOfProbesPerSegment = new int[totalSegmentPerSample];
//////        double[] log_ratioPerSegment = new double[totalSegmentPerSample]; //每个分段的log值
//////        List Segment = new ArrayList<>();
//////
//////
//////        //赋值
//////        Segment.add(samplePerSegment);
//////        Segment.add(chromosomePerSegment);
//////        Segment.add(startPointPerSegment);
//////        Segment.add(endPointPerSegment);
//////        Segment.add(countsOfProbesPerSegment);
//////        Segment.add(log_ratioPerSegment);
////
////        return Segment;
////    }
//}
